﻿using StarsAdmin.Core.Enums;
using StarsAdmin.Core.Models;

namespace StarsAdmin.Core.DB.Entities
{
    /// <summary>
    /// 菜单实体
    /// </summary>
    public class MenuEntity : BaseEntity, ITree<MenuEntity>
    {
        /// <summary>
        /// 菜单名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 菜单路由地址
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// 组件位置
        /// </summary>
        public string ComponentPath { get; set; }

        /// <summary>
        /// 菜单重定向地址
        /// </summary>
        public string Redirect { get; set; }

        /// <summary>
        /// 菜单图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 菜单类型
        /// </summary>
        public MenuTypeEnum Type { get; set; }

        /// <summary>
        /// 权限字段
        /// </summary>
        public string Permission { get; set; }

        /// <summary>
        /// 菜单描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnabled { get; set; }

        /// <summary>
        /// 是否在菜单栏显示
        /// </summary>
        public bool IsHidden { get; set; }

        /// <summary>
        /// 是否缓存
        /// </summary>
        public bool IsKeepalive { get; set; }

        /// <summary>
        /// 是否固定在标签页
        /// </summary>
        public bool IsAffis { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; } = 100;

        /// <summary>
        /// 父级菜单Id
        /// </summary>
        public long? ParentId { get; set; }

        /// <summary>
        /// 父级菜单
        /// </summary>
        public virtual MenuEntity Parent { get; set; }

        /// <summary>
        /// 子级菜单
        /// </summary>
        public virtual ICollection<MenuEntity> Children { get; set; } = new List<MenuEntity>();

        public long[]? RoleIds { get; set; }
        public virtual ICollection<RoleEntity> Roles { get; set; } = new List<RoleEntity>();
        public long[]? ApiIds { get; set; }
        public virtual ICollection<ApiEntity> Apis { get; set; } = new List<ApiEntity>();
    }
}